﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Simple.Repository.Models.Article;

namespace Simple.Repository.Models.Market
{
    /// <summary>
    /// 商品图片
    /// </summary>
    public class CommodityImage  : BusinessFullEntityBase<Guid>
    {
        /// <summary>
        /// 文件Id
        /// </summary>
        public Guid? FiledId { get; set; }

        /// <summary>
        /// 文件名称
        /// </summary>
        public string FileName { get; set; } = "";

        /// <summary>
        /// 文件大小
        /// </summary>
        public string FileSize { get; set; } = "";

        /// <summary>
        /// 商品Id
        /// </summary>
        public Guid? CommodityId { get; set; } = null;

        /// <summary>
        /// 商品
        /// </summary>
        public Commodity CommodityInfo = new Commodity();

        public override void ConfigureEntity(ModelBuilder builder)
        {
            builder.Entity<CommodityImage>(entity =>
            {
                entity.ToTable("Commodity_Image");
                entity.HasOne(c => c.CommodityInfo).WithMany(c => c.Images).HasForeignKey(c => c.CommodityId);
            });
        }
    }
}
